package com.example2.demo.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.codingapi.tx.annotation.ITxTransaction;
import com.example2.demo.dao.TestDao;
import com.example2.demo.entity.TestEntity;
import com.example2.demo.service.TestService;
import com.jxzx.common.utils.PageUtils;
import com.jxzx.common.utils.QueryPage;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;


@Service("testService")
public class TestServiceImpl extends ServiceImpl<TestDao, TestEntity> implements TestService, ITxTransaction {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<TestEntity> page = this.selectPage(
                new QueryPage<TestEntity>(params).getPage(),
                new EntityWrapper<TestEntity>()
        );

        return new PageUtils(page);
    }
    @Override
    public List<TestEntity> list() {
        return this.selectList(null);
    }


    @Override
    @Transactional
    public int save() {
        this.baseMapper.queryOneTestEntity(1);
//        boolean insert = this.insert(new TestEntity("mybatis-plus-hello-2"));
//        int rs = this.baseMapper.insert(new TestEntity("mybatis-plus-hello-2"));
//        int rs = this.baseMapper.save(new TestEntity("mybatis-plus-hello-2"));
        return 0;
    }
}
